CC = gcc
CFLAGS = -g
OUT = ./out
MKDIR = mkdir

$(OUT)/asproxy: $(OUT)/main.o $(OUT)/proxydaemon.o $(OUT)/proxyconfigfile.o \
		$(OUT)/log.o $(OUT)/proxythread.o $(OUT)/proxyhelper.o

	$(CC) $(CFLAGS) -o $(OUT)/asproxy $(OUT)/main.o \
		$(OUT)/proxydaemon.o $(OUT)/proxyconfigfile.o \
		$(OUT)/log.o $(OUT)/proxythread.o $(OUT)/proxyhelper.o \
		-lpthread -lssl -lcrypt	-ldl

$(OUT)/main.o: ./main.c 
	$(CC) $(CFLAGS) -o $(OUT)/main.o -c ./main.c

$(OUT)/proxydaemon.o: ./proxydaemon.c ./proxydaemon.h
	$(CC) $(CFLAGS) -o $(OUT)/proxydaemon.o -c ./proxydaemon.c

$(OUT)/proxyconfigfile.o: ./proxyconfigfile.c ./proxyconfigfile.h
	$(CC) $(CFLAGS) -o $(OUT)/proxyconfigfile.o -c ./proxyconfigfile.c

$(OUT)/log.o: ./log.c ./log.h
	$(CC) $(CFLAGS) -o $(OUT)/log.o -c ./log.c

$(OUT)/proxythread.o: ./proxythread.c ./proxythread.h
	$(CC) $(CFLAGS) -o $(OUT)/proxythread.o -c ./proxythread.c

$(OUT)/proxyhelper.o: ./proxyhelper.c ./proxyhelper.h
	$(CC) $(CFLAGS) -o $(OUT)/proxyhelper.o -c ./proxyhelper.c

clean: 
	$(RM) $(OUT)/*.o $(OUT)/asproxy

setup: 
	$(MKDIR) $(OUT)
